// pages/mine/order/order.js
var uid
Page({

  
  data: {
    more:'0%', change:1, ding:1,nomoneylist:[],order:1,noprintlist:[],comlelist:[],tuimoney:[],everylist:[],num:'',page:1,value:1,array:['1页3条',"1页5条",'1页10条'],index1:0,limit:3
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var more = (options.change-1)*20;
    more = more+'%';
    this.setData({
      change:options.change,
      more:more,
      ding:options.change,
      order:options.change
    })

    var that = this
     uid = wx.getStorageSync('uid');
    wx.request({
      url: 'https://zujieba.com/api/order/mine_order.html', //仅为示例，并非真实的接口地址
      data: {
        uid:uid,
        type:that.data.change,
        page:1, 
        limit:this.data.limit,
      },
      success: function(res){
        that.setData({num:res.data.data.num?res.data.data.num :0})
        if(options.change==1){ that.setData({
          nomoneylist:res.data.data.data
        })}else if(options.change==2){
          console.log(res);
          
          that.setData({noprintlist:res.data.data.data})
        } else if(options.change==3){
          that.setData({comlelist:res.data.data.data})
        }else if(options.change==4){
          that.setData({tuimoney:res.data.data.data})
        }else{
          that.setData({everylist:res.data.data.data})
        }
        
       
        }
    })

    console.log(this.data.change);
    // var query = wx.createSelectorQuery();
    // //选择id
    // query.select('.order_content').boundingClientRect()
    // query.exec(function(res) {
    //     //res就是 所有标签为mjltest的元素的信息 的数组
    //     console.log(res);
    // })

  },


  dian:function(e){
    this.setData({
   order:e.currentTarget.dataset.order,
   page:1,
   value:1
    })

    
    var order = e.currentTarget.dataset.order;
    if(this.data.change == order){
      return false;
    }else{
      var dong = 0;
      dong = (order-this.data.ding)*20;
      dong = dong+'%';
      // console.log(order);
      this.setData({
        change:order,
        // more:dong
      })
    }
    
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: 'ease',
    });
    var width= wx.getSystemInfoSync().windowWidth;
    width = (width/5)*(order-this.data.ding);
    // return false;
    animation.translate(width,0).step()
    this.setData({
      ani:animation.export()
    })
    /*this.getlist(wx.getStorageSync('uid'),this.data.change)*/
    this.getlist(uid,e.currentTarget.dataset.order,1,this.data.limit)
     
  },
  getlist(uid,type,page,limit){
    wx.request({
      url: 'https://zujieba.com/api/order/mine_order.html',
      data:{uid,type,page,limit},
      success:(res)=>{    
        this.setData({num:res.data.data.num?res.data.data.num :0})
        if(type==1){ this.setData({
          nomoneylist:res.data.data.data
        })}else if(type==2){
          console.log(res);
          
          this.setData({noprintlist:res.data.data.data})
        } else if(type==3){
          this.setData({comlelist:res.data.data.data})
        }else if(type==4){
          this.setData({tuimoney:res.data.data.data})
        }else{
          this.setData({everylist:res.data.data.data})
          console.log(res);
          
        }
        
           
           
      }
    })
  },
  click1(){
    this.getlist(uid,this.data.order,1,this.data.limit)
    this.setData({
      page:1
    })

  },
  click2(){
    this.getlist(uid,this.data.order,2,this.data.limit)
    this.setData({
      page:2
    })
  },
  click3(){
    this.getlist(uid,this.data.order,3,this.data.limit)
    this.setData({
      page:3
    })
  },
  click4(){
    this.getlist(uid,this.data.order,4,this.data.limit)
    this.setData({
      page:4
    })
  },
  click5(){
    let page=this.data.page+1
    this.setData({page})
    this.getlist(uid,this.data.order,page,this.data.limit)

  },
  click6(){
    if(this.data.page==1){return}
    let page=this.data.page-1
    this.setData({page})
    this.getlist(uid,this.data.order,page,this.data.limit)

  },
  change(e){
    setTimeout(()=>{
      console.log(e);
      let value=e.detail.value
      this.setData({page:parseInt(value)})
      this.getlist(uid,this.data.order,parseInt(value),this.data.limit)
    },1000)
        
        
  },
  bindPickerChange(e){
    console.log(e);
    this.setData({index1:e.detail.value})
    var limit 
    if(e.detail.value==0){
      
      
   limit=3
    }else if(e.detail.value==1){limit=5}
    else{limit=10}
    this.setData({limit})
    this.getlist(uid,this.data.order,this.data.page,limit)
    
  },
  

})